﻿using System;
using System.IO.Ports;

namespace BGM.Sensors.MeasuringDevice
{
   internal class CustomSerialPort: SerialPort, IPort
    {
        public CustomSerialPort(string portName,int baudRate,Parity parity,int dataBits,StopBits stopBits):base(portName,baudRate,parity,dataBits,stopBits)
        {
                        base.DataReceived += new SerialDataReceivedEventHandler(CustomSerialPort_DataReceived);
        }

        void CustomSerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            OnDataReceived();
        }
        protected void OnDataReceived()
        {
            EventHandler handler = DataReceived;
            if (handler != null)
                handler(this, new EventArgs());
        }
        #region IPort Members


        public new event EventHandler DataReceived;

        #endregion
    }
}
